package com.wing.sell.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wing.mybatis.common.BaseEntity;
import com.wing.system.model.entity.SystemEnterprise;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 跟进记录管理
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("sel_customer_follow_record")
public class CustomerFollowRecord extends BaseEntity<CustomerFollowRecord> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum CustomerType implements IEnum<Integer> {

        /**
        * 潜在客户
        */
        potential(1,"潜在客户"),
        /**
        * 意向客户
        */
        Intended(2,"意向客户"),
        /**
        * 正式客户
        */
        formal(3,"正式客户");

        private int code;
        private String desc;

        CustomerType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 客户类型
     */
    private CustomerType customerType;

    /**
    * 客户类型描述
    */
    @TableField(exist = false)
    private String customerTypeDesc;

    public String getCustomerTypeDesc() {
        return customerType == null ? null : customerType.getDesc();
    }

    /**
     * 跟进类型
     */
    private String followType;

    /**
     * 跟进客户
     */
    private Long followCustomer;

    /**
     * 跟进对象
     */
    private Long followTarget;

    /**
     * 跟进方式
     */
    private String followWay;

    /**
     * 跟进结果类型:A0001-目标达成;A0002-基本达成，有问题要解决;A0003-基本达成，等待对方审核;A0004-没有达成;
     */
    private String followResult;

    /**
     * 产生费用
     */
    private BigDecimal cost;

    /**
     * 跟进结果描述
     */
    private String followDescribe;

    /**
     * 审批人
     */
    private String approver;

    /**
     * 审批人姓名
     */
    private String approverName;

    /**
     * 审核时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected LocalDateTime checkTime;

    public enum Status implements IEnum<Integer> {

        /**
         * 待审核
         */
        pendingReview(1,"待审核"),
        /**
         * 已审核
         */
        audited(2,"已审核");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 状态
     */
    private Status status;

    /**
     * 状态描述
     */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

}
